package com.cloudalibabaseataorder10088.service.impl;

import com.cloudalibabaseataorder10088.entity.Goods;
import com.cloudalibabaseataorder10088.feign.FeignConfig;
import com.cloudalibabaseataorder10088.mapper.GoodsMapper;
import com.cloudalibabaseataorder10088.service.GoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author zx
 * @since 2024-12-06
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;
    @Resource
    private FeignConfig feignConfig;

    @Override
    public void add() {

        // 扣减库存
        feignConfig.deduct();

        // 模拟异常
        // int i = 1/0;

        // 创建订单
        Goods goods = new Goods();
        goods.setGoodsNum("1001");
        goodsMapper.insert(goods);
    }
}
